package com.sgb.kjwl.view.ui.adapter.pick;

import android.content.Context;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.view.selection.CommonPopEntity;

import java.util.List;

public class PickCategoryRightAdapter extends BaseRecycleAdapter<CommonPopEntity> {

    private Context context;
    private int position;

    public PickCategoryRightAdapter(Context context, List<CommonPopEntity> datas) {
        super(context, R.layout.item_pick_category_right, datas);
        this.context = context;
    }

    @Override
    public void convert(ItemViewHolder holder, CommonPopEntity entity) {
        holder.setBinding(BR.viewModel, entity);

        TextView textView = holder.itemView.findViewById(R.id.logo_view);
        if(holder.getLayoutPosition() > 3){
            position = holder.getIndex_position() % 4;
        }else{
            position = holder.getIndex_position();
        }

        switch (position) {
            case 0:
                textView.setBackground(context.getDrawable(R.mipmap.pick_category_right1));
                break;
            case 1:
                textView.setBackground(context.getDrawable(R.mipmap.pick_category_right2));
                break;
            case 2:
                textView.setBackground(context.getDrawable(R.mipmap.pick_category_right3));
                break;
            case 3:
                textView.setBackground(context.getDrawable(R.mipmap.pick_category_right4));
                break;
        }
        if (entity.getPickerViewText().length() > 4) {
            textView.setText(entity.getPickerViewText().substring(0, 4));
        } else {
            textView.setText(entity.getPickerViewText());
        }

    }
}
